/**
 * 追号记录部分前端代码
 */

// 获取页面数据
var resData = '';
$.ajax({  
	type:'post',    
    url: getDataUrl,  
    data:'operation=itemmore&oid=' + $('#id_order_item_id').val(),  
    cache:false,  
    dataType:'json',  
    async:false,
    success:function(res){  
    	resData = res;
    }  
})
console.log(resData);
$('#id_bet_time').html(resData.orderView.re_createtime);
$('#id_lott_period').html(resData.orderView.period);
$('#id_bet_amount').html(resData.orderView.amount);
$('#id_bet_orderno').html(resData.orderView.order_no);
//$('#id_bet_prize').html(resData.orderView.prize);
$('#id_user_name').html(resData.userInfo.userName);

if($.isEmptyObject(resData.orderView.open_code)){
	$('#id_period_opencode').html('未开奖');
}else{
	$('#id_period_opencode').html(resData.orderView.open_code);
}

// 清空列表
$('#id_item_detail').html('');
$.each(resData.betPlayData, function (i, v){
	var str = '<tr style="font-size: 12px;">';
	str    += '	<td>' + v.cn_play + '</td>';
	str    += '	<td><div class="betNum" id="id_betting_str">' + v.betting_str + '</div><a href="javascript:void(0);" class="NumLink tag_show_betting_str" style="color: rgb(74, 169, 187); line-height: 37px;" amv="' + v.betting_str + '">[详情]</a></td>';
	str    += '	<td>' + v.num + '</td>';
	str    += '	<td>' + v.multiple + '</td>';
	str    += '	<td>' + v.money + '</td>';
	switch(v.money_unit.toString()){
		case '1.00':
			unit = '元';
			break;
		case '0.10':
			unit = '角';
			break;
		case '0.01':
			unit = '分';
			break;
		default:
			unit = '元';
			break;
	}
	str    += '	<td>' + unit + '</td>';
	str    += '	<td>' + v.prize + '</td>';
	if(v.winner == '0'){
		win = '未开奖';
	}else if (v.winner == '1'){
		win = '未中奖';
	}else if(v.winner == '2'){
		win = '已中奖';
	}
	str    += '	<td>' + win + '</td>';
	str	   += '</tr>';
	$('#id_item_detail').append(str);
	$('#id_bet_prize').html(function (){
		return (parseFloat($('#id_bet_prize').html()) + v.prize);
	});
})

$('#id_item_detail').on('click', '.tag_show_betting_str', function (){
	showMsg('投注内容', $(this).attr('amv'));
})
$('#id_lott_title').html(resData.orderView.lott_title);
$('#id_bet_lott_title').html(resData.orderView.lott_title);
$('#id_item_period').html(resData.orderView.period);
$('#id_user_name').html(resData.orderView.userName);
function showMsg(title, content){
	layer.open({
        title: title,
        content: content,
        className: 'layui-m-tag-msg',
        btn: ['确定'],
        yes: function (index){
			// 继续投注
        	layer.close(index);
        },
    });
}
